﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using libDAL;
using System.Windows.Forms;
 
namespace libAuditTrail
{

    public class clsInsertAuditTrail : IDisposable
    {
        private cls_DAL _DAL;
        private string strCon = "Data Source=esbserver5;Initial Catalog=ESB_AuditTrail;User ID=sa;Password=esbsql*()";

        public clsInsertAuditTrail()
        {
            _DAL = new cls_DAL(strCon);
        }

       public void set_AuditTrailRecord(string strEmployeeID, string strModuleId,
                               string strDetailsOfAction, string strCurrentRecord, string strNewRecord,string strBranch)
       {
           try
           {
               string strQuery = "insert into AuditTrail (EmployeeID, ModuleID, atAuditRecorded, atActionDetails, atPreviousRecord," +
                                                          "atNewRecord, atIPAddress, atHostName, atBranch, DateTimeInserted) " +
                                                          "values ('" + strEmployeeID + "', '" + strModuleId + "',getdate(), " +
                                                          "'" + strDetailsOfAction + "', '" + strCurrentRecord + "', '" + strNewRecord + "', " +
                                                          "'" + clsGenFunction.getHostIP() + "', '" + clsGenFunction.getHostName()  + "', " +
                                                          "'" + strBranch + "', getdate())";
               _DAL.set_GenQueryExNonQuery(strQuery);
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message + " libAuditTrail_clsInsertAuditTrail_set_AuditTrailRecord"); 
           }
       
       }
                                                          //get_CurrentEmployeeRecord(),
                                                          //get_NewEmployeeRecord(),
                                                          //clsGenFunction.getHostIP(),
                                                          //clsGenFunction.getHostName1(),
                                                          //_BUS.getset_Branch,
                                                          //clsGenFunction.get_ServerDateTimeRAW(_BUS.get_DAL));

        public void Dispose()
        {
            _DAL.Close_Connection();
            GC.Collect();
        }
    }
}
